
{% extends "user_base.html" %}
{% block title %}
健康资讯
{% endblock %}

{% block subtitle %}
健康新闻
{% endblock %}


{% block main %}健康资讯{% endblock %}

{% block content %}

<div class="pagetitle">
  <nav>
    <div class="search-bar" style="display: inline-flex;">
      <form class="search-form d-flex align-items-center" method="get" action="{% url 'UserApp:news' %}">
          <input type="text" name="q" placeholder="搜索新闻" title="Enter search keyword" value="{{q}}">
          <button type="submit" title="Search"><i class="bi bi-search"></i></button>
      </form>
    </div>
    {% if q %}
    <p>题目中包含“{{q}}”的新闻如下</p>
    {% endif %}
    

  </nav>
</div><!-- End Page Title -->

<!-- 新闻开始 -->
<section class="section dashboard">
  <div class="row">

    <!-- Left side columns -->
    <div class="col-lg-12">
      <div class="row">




        <!-- News & Updates Traffic -->
        <div class="card">


          <div class="card-body pb-0">
            <h5 class="card-title">相关新闻<span> | 2023.03.05</span></h5>

            <div class="news">
              {% for n in news %}
              <div class="post-item clearfix">
                <img src="{{ n.news_img }}" alt="">
                <h4><a href="{% url 'UserApp:news_details'%}?nid={{n.news_id}}">{{n.news_title}}</a></h4>
                <p>{{n.news_content}}</p>
              </div>
              {% endfor %}
            </div><!-- End sidebar recent posts-->

            <nav aria-label="Page navigation example">
              <ul class="pagination justify-content-end">

                {% if news.has_previous %}
                <li class="page-item">
                  <a class="page-link" href="{% url 'UserApp:news' %}?p={{news.previous_page_number}}">上一页</a>
                </li>
                {% else %}
                <li class="page-item disabled">
                  <a class="page-link" href="#">上一页</a>
                </li>
                {% endif %}
                {% for num in news.paginator.page_range%}
                {% if news.number == num%}
                <li class="page-item active"><a class="page-link" href="{% url 'UserApp:news' %}?p={{num}}">{{ num}}</a></li>
                {% else %}
                <li class="page-item"><a class="page-link" href="{% url 'UserApp:news' %}?p={{num}}">{{ num }}</a></li>
                {% endif %}
                {% endfor %}
                {% if news.has_next %}
                <li class="page-item">
                  <a class="page-link" href="{% url 'UserApp:news' %}?p={{news.next_page_number}}">下一页</a>
                </li>
                {% else %}
                <li class="page-item disabled">
                  <a class="page-link" href="#">下一页</a>
                </li>
                {% endif %}

              </ul>
            </nav>

          </div>
        </div><!-- End News & Updates -->


      </div><!-- End Right side columns -->



    </div>
</section>

<!-- 新闻结束 -->

{% endblock %}